unit VendasdoPeriodo;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, Mask, ComCtrls;

type
  TFormVendasdoPeriodo = class(TForm)
    BT1: TButton;
    BT2: TButton;
    BT3: TButton;
    GroupBox1: TGroupBox;
    Label1: TLabel;
    MaskEdit1: TMaskEdit;
    Label2: TLabel;
    MaskEdit2: TMaskEdit;
    BTOK: TBitBtn;
    BTCancel: TBitBtn;
    StatusBar1: TStatusBar;
    procedure BT2Click(Sender: TObject);
    procedure BT3Click(Sender: TObject);
    procedure MaskEdit1Exit(Sender: TObject);
    procedure MaskEdit2Exit(Sender: TObject);
    procedure MaskEdit2KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure MaskEdit1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure BTCancelClick(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure BTOKClick(Sender: TObject);
    procedure BT1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FormVendasdoPeriodo: TFormVendasdoPeriodo;
  Resposta:Integer;

implementation

uses Principal, declaracoes, funcoesapoio;

{$R *.dfm}


procedure TFormVendasdoPeriodo.BT2Click(Sender: TObject);
begin
      MessageDlg('Esta função deverá gerar arquivo conforme leiaute estabelecido'+chr(13)+
                     'no Ato Cotepe/ICMS 09/08' + chr(13) +
                     'Tabela de Blocos: O, H e 9' , mtINformation, [mbOK], 0);

end;

procedure TFormVendasdoPeriodo.BT3Click(Sender: TObject);
begin
        Close;
end;

procedure TFormVendasdoPeriodo.MaskEdit1Exit(Sender: TObject);
begin
                try
                        StrToDate(MaskEdit1.Text)
                except
                        ShowMessage('Data inválida!');
                        MaskEdit1.SetFocus;
                end;

end;

procedure TFormVendasdoPeriodo.MaskEdit2Exit(Sender: TObject);
begin
                try
                        StrToDate(MaskEdit2.Text)
                except
                        ShowMessage('Data inválida!');
                        MaskEdit2.SetFocus;
                end;


end;

procedure TFormVendasdoPeriodo.MaskEdit2KeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
        if Key = VK_RETURN then BTOk.SetFocus;

end;

procedure TFormVendasdoPeriodo.MaskEdit1KeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
        if Key = VK_RETURN then MaskEdit2.SetFocus;

end;

procedure TFormVendasdoPeriodo.BTCancelClick(Sender: TObject);
begin
        GroupBox1.Visible:=False;
        Close;
end;

procedure TFormVendasdoPeriodo.FormActivate(Sender: TObject);
begin
        GroupBox1.Visible:=False;

end;

procedure TFormVendasdoPeriodo.BTOKClick(Sender: TObject);
Const Razao:String='Sweda Informática Ltda';
    Endereco: String='Rua Dona Brigida ';
    Numero:String='713';
    Bairro:String='Vila Mariana';
    Cidade:String='São Paulo';
    UF:String='SP';
    CEP:String='03.378-010';
    Telefone:String='(11) 2106-5574';
    Fax:String='(11) 5572-4799';
    Contato:String='Suporte Software';
var
    arquivo:TextFile;
begin
      MessageDlg('Esta função deverá gerar arquivo conforme leiaute estabelecido'+chr(13)+
                     'no Manual de Orientação do Convênio 57/95' + chr(13) +
                     'Registros: 10, 11, 75 e 90 ', mtINformation, [mbOK], 0);
      GroupBox1.Visible:=True;
      FormPrincipal.Statusbar1.Panels[0].Text:='Sintegra';

      Resposta:=ECF_ArquivoSintegra2004MFD(32,'C:\SWEDA\SINTEGRA.TXT',Copy(maskEdit1.Text,1,3)+Copy(maskEdit1.Text,4,2),Copy(maskEdit1.Text,7,4),
      Copy(maskEdit2.Text,1,3)+Copy(maskEdit2.Text,4,2),Copy(maskEdit2.Text,7,4), Format('%50s',[Razao]),FOrmat('%50s',[Endereco]),Format('%10s',[numero]),
      Format('%30s',[' ']), Format('%40s',[Bairro]),Format('%40s',[Cidade]),UF,Format('%15s',[CEP]),Format('%20s',[Telefone]),
      Format('%20s',[Fax]), Format('%40s',[Contato]));
      if Resposta=1 then StatusBar1.Panels[0].Text:='C:\SWEDA\SINTEGRA.TXT'
      else  StatusBar1.Panels[0].Text:='';
        VerificaRetornoFuncao(Resposta);

        // NESTE PONTO SERÁ NECESSÁRIO INCLUIR A ASSINATURA DA SOFTWARE HOUSE
        // REGISTRO EAD
        If FileExists('C:\SWEDA\SINTEGRA.TXT') then
        begin
                AssignFile(Arquivo,'C:\SWEDA\SINTEGRA.TXT');
                Append(Arquivo);
                Write(Arquivo,'EAD - Inserir a Assinatura Digital da Software House');
                CloseFile(Arquivo);
        end;
        GroupBox1.Visible:=False;

end;

procedure TFormVendasdoPeriodo.BT1Click(Sender: TObject);
begin
        GroupBox1.Visible:=True;
end;

end.
